package com.king.im.server;

import lombok.extern.slf4j.Slf4j;
import org.tio.server.ServerGroupContext;
import org.tio.websocket.server.WsServerStarter;
import org.tio.websocket.server.handler.IWsMsgHandler;

import java.io.IOException;

@Slf4j
public class IMServerStarter {
    private WsServerStarter start;

    public IMServerStarter(int port) throws IOException {
        IWsMsgHandler handler = new IMWsMsgHanlder();
        start = new WsServerStarter(port,handler);

        ServerGroupContext serverGroupContext = start.getServerGroupContext();
        serverGroupContext.setHeartbeatTimeout(1000 * 60);//10s心跳

        /*serverGroupContext.setServerAioListener();*/
    }

    public void start() throws IOException {
        start.start();
        log.info("tio server 启动成功！");
    }
}
